/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package PackageMaker.Config;

import java.io.File;

/**
 *
 * @author wcss
 */
public class FilesModel {

    public static FilesModel load(String path) throws Exception {
        if (new File(path).exists()) {
            return (FilesModel) ObjectToXMLUtil.loadObjectFromXml(path);
        } else {
            return null;
        }
    }

    public static void save(FilesModel entry, String path) throws Exception {
        ObjectToXMLUtil.saveObjectToXml(entry, path);
    }
    
    public static final int copyFile = 10;
    public static final int copyDir = 20;

    public FilesModel() {
    }

    public FilesModel(String source, String dest, int type) {
        this.sourcePath = source;
        this.destPath = dest;
        this.copyType = type;
    }
    /**
     * 源文件位置
     */
    public String sourcePath = "";
    /**
     * 目标文件位置
     */
    public String destPath = "";
    /**
     * 操作说明
     */
    public String copyInfo = "";
    /**
     * 操作类型
     */
    public int copyType = 0;

    public String toString() {
        if (destPath != null) {
            File f = new File(destPath);
            if (copyType == FilesModel.copyFile) {
                return f.getName() + "(File)";
            } else {
                return f.getName() + "(Dir)";
            }
        } else {
            return "UnKnown";
        }
    }
}
